clear all

use Master2018.dta

// The data is next collapsed at the Lok Sabha overall session level

replace LS_overall = LS_overall[_n-1] if missing(LS_overall)

egen session_length = sum(LSsession), by(LS_overall)
egen break_length = sum(LSbreak), by(LS_overall)

keep if ordinances > 0

expand ordinances

sort date

gen id = _n
rename became_bill converted
gen became_bill = 1 if converted == ordinances
replace became_bill = 0 if converted == 0

/* 
The following replaces those days with more than one ordinances
that had some but not all ordinances converted into bills
*/

replace became_bill = 1 in 222
replace became_bill = 1 in 223
replace became_bill = 0 in 224
replace became_bill = 1 in 250
replace became_bill = 0 in 251
replace became_bill = 1 in 353
replace became_bill = 1 in 354
replace became_bill = 0 in 355
replace became_bill = 1 in 385
replace became_bill = 0 in 386
replace became_bill = 1 in 406
replace became_bill = 1 in 407
replace became_bill = 1 in 408
replace became_bill = 0 in 409
replace became_bill = 1 in 444
replace became_bill = 0 in 445
replace became_bill = 1 in 451
replace became_bill = 0 in 452
replace became_bill = 0 in 453
replace became_bill = 0 in 454
replace became_bill = 0 in 455
replace became_bill = 1 in 483
replace became_bill = 1 in 484
replace became_bill = 0 in 485
replace became_bill = 1 in 486
replace became_bill = 0 in 487
replace became_bill = 1 in 489
replace became_bill = 1 in 490
replace became_bill = 1 in 491
replace became_bill = 0 in 492
replace became_bill = 1 in 510
replace became_bill = 0 in 511
replace became_bill = 0 in 512
replace became_bill = 1 in 526
replace became_bill = 0 in 527
replace became_bill = 1 in 555
replace became_bill = 0 in 556
replace became_bill = 1 in 600
replace became_bill = 0 in 601


rename date date1

gen date = (date1 - 31910) / 3650

label var LSmaj "LS Majority"
label var LegisMaj "Majority"

label var yr_bef_elec "Yr before  election"
label var effectpartvote "Effective num parties"
label var cong_govt "Congress govt"
label var date "Linear time trend"

local session_ctls "break_length session_length i.sessionwithinloksabha"
local pol_ctls "effectpartvote cong_govt"

// The next 7 lines replicate the regressions in Table 7 from the paper
eststo electionyr_1: reg	became_bill c.LegisMaj##c.yr_bef_elec, robust 
eststo electionyr_2: reg	became_bill c.LegisMaj##c.yr_bef_elec i.month_id, robust 
eststo electionyr_3: reg	became_bill c.LegisMaj##c.yr_bef_elec i.month_id `session_ctls', robust 
eststo electionyr_4: reg	became_bill c.LegisMaj##c.yr_bef_elec i.month_id `session_ctls' `pol_ctls' , robust 
eststo electionyr_5: reg	became_bill c.LegisMaj##c.yr_bef_elec i.month_id `session_ctls' `pol_ctls' date, robust 
eststo electionyr_6: reg 	became_bill c.LegisMaj##c.yr_bef_elec i.month_id `session_ctls'  i.loksabhainsession, robust 
eststo electionyr_7: reg 	became_bill c.LegisMaj##c.yr_bef_elec i.month_id `session_ctls'  i.year, robust 


eststo LS_electionyr_1: reg	became_bill c.LSmaj##c.yr_bef_elec, robust 
eststo LS_electionyr_2: reg	became_bill c.LSmaj##c.yr_bef_elec i.month_id, robust 
eststo LS_electionyr_3: reg	became_bill c.LSmaj##c.yr_bef_elec i.month_id `session_ctls', robust 
eststo LS_electionyr_4: reg	became_bill c.LSmaj##c.yr_bef_elec i.month_id `session_ctls' `pol_ctls' , robust 
eststo LS_electionyr_5: reg	became_bill c.LSmaj##c.yr_bef_elec i.month_id `session_ctls' `pol_ctls' date, robust 
eststo LS_electionyr_6: reg 	became_bill c.LSmaj##c.yr_bef_elec i.month_id `session_ctls'  i.loksabhainsession, robust
eststo LS_electionyr_7: reg 	became_bill c.LSmaj##c.yr_bef_elec i.month_id `session_ctls'  i.year, robust


#delimit ;
local common_tab_opts
star(* 0.1 ** 0.05 *** 0.01)
varwidth(30) modelwidth(10) wrap se r2 nobase noomitted 
label numbers nodepvars
;
#delimit cr

local conversion_opts	`common_tab_opts' indicate("Month dummies = *.month_id" "Session controls = break_length session_length *.sessionwithinloksabha" "Lok Sabha dummies = *.loksabhainsession" "Year dummies = *.year")

esttab electionyr_*		, `conversion_opts' nomtitles scalar("test_p \$p\$-value \$H_0: \beta_A + \lambda = 0\$" ) sfmt(3)
esttab LS_electionyr_*	, `conversion_opts' nomtitles scalar("test_p \$p\$-value \$H_0: \beta_A + \lambda = 0\$" ) sfmt(3)

/*
esttab electionyr_*		using "tables/electionyr.tex" , `conversion_opts' nomtitles mgroups("OLS" "OLS" "OLS" "OLS" "OLS" "OLS" "Logit" "Probit", pattern(1 1 1 1 1 1 1 1) span prefix(\multicolumn{@span}{c}{) suffix(})) replace
esttab LS_electionyr_*	using "tables/LS_electionyr.tex" , `conversion_opts' nomtitles mgroups("OLS" "OLS" "OLS" "OLS" "OLS" "OLS" "Logit" "Probit", pattern(1 1 1 1 1 1 1 1) span prefix(\multicolumn{@span}{c}{) suffix(})) replace
*/


esttab electionyr_*		using "tables/electionyr.tex" , `conversion_opts' nomtitles replace
esttab LS_electionyr_*	using "tables/LS_electionyr.tex" , `conversion_opts' nomtitles replace
